/* eslint-disable max-len */
import commonjs from '@rollup/plugin-commonjs';
import {terser} from 'rollup-plugin-terser';
import banner2 from 'rollup-plugin-banner2';
import json from '@rollup/plugin-json';
import copy from 'rollup-plugin-copy';
import typescript from "rollup-plugin-typescript2";
import clear from 'rollup-plugin-clear'

const pkg = require('./package.json');

const targets = [
  {
    input: 'src/index.ts',
    plugins: [
      clear({
        targets:['dist'],
        watch:true
      }),
      typescript(),
      commonjs(),
      banner2(() => `/**
   * Cache.js v${pkg.version}
   * ${pkg.description}
   * @${pkg.author}
   * ${pkg.repository.url}
   */
  `),
      json(),
      copy({
        targets: [
          {src: ['CHANGELOG.md', 'LICENSE', 'README.md', 'package.json'], dest: 'dist'},
        ],
      }),
    ],
    output: [
      {file: 'dist/cache.esm.js', format: 'esm', name:'Cache', sourcemap: true, plugins: [terser()]},
    ],
  },
];

export default targets;
